
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
      <link href="css/bootstrap.min.css" rel="stylesheet">
        <link href="css/animate.min.css" rel="stylesheet">
        <link href="css/font-awesome.min.css" rel="stylesheet">
        <link href="css/form.css" rel="stylesheet">
        <link href="css/calendar.css" rel="stylesheet">
        <link href="css/media-player.css" rel="stylesheet">
        <link href="css/style.css" rel="stylesheet">
        <link href="css/icons.css" rel="stylesheet">
        <link href="css/generics.css" rel="stylesheet"> 
        <link rel="stylesheet" type="text/css" href="css/main.css"/>
        <script src="js/angular.min.js"></script>
		<script src="js/jquery-3.3.1.min.js"></script>
</head>
<body id="skin-blur-violate" ng-app="myApp" ng-controller="myCtrl">
 			<div class="block-area" id="tableStriped">
                
             	
                    <table  >
                        <tr>
                            <th width="120">选择分类:</th>
                            <td>
                                <select name="search" id="" style="background-color:rgba(255,255,255,0)">
                                    <option value="全部">全部</option>
                                    <option value="设备ID">设备ID</option>
                                    <option value="设备名称">设备名称</option>
                                </select>
                            </td>
                            <th width="110" >关键字:</th>
							<td><input style="background-color:rgba(255,255,255,0)" placeholder="关键字" name="deviceName" value="" id="" type="text" ng-model="title"></td>
						
                            <td><input class="btn btn-primary btn2" name="sub" value="查询" type="submit"  ng-click="Btnled2()"></td>
                        </tr>
                    </table>
                
                
                 
		                <div class="result-title">
		                    <div class="result-list">
								<span class="btn btn-file btn-alt btn-sm">
									<span class="fileupload-new" ng-click="Btnled()">更新实时数据</span>
								</span>
		                        
		                    </div>
		                </div>
		             <h2>商品信息信息</h2>
                        <table class="tile table table-bordered table-striped">
                            <thead>
                                <tr>
                                	<th>商品名称</th>
									<td>商品规格</td>	                              
									<td>价格</td>
									<td>原价</td>
									<td>详细信息</td>
									<td>时间</td>
		                            <td>操作</td>
                                </tr>
                            </thead>
                            	
		                        <tr ng-repeat="page in pagelist" >
									<td>{{page.name}}</td>
									<td>{{page.spec}}</td>
									<td>{{page.price}}</td>
									<td>{{page.marketprice}}</td>
									<td>{{page.content}}</td>
									<td>{{page.date}}</td>
		                           <td>
									<span class="btn btn-file btn-alt btn-sm">
										<span class="fileupload-new" ng-click="Btnled3(page.name,page.date)">删除</span>
									</span>
		                             
		                           </td>
		                        </tr>
                        		</c:forEach>
                            </tbody>
                        </table>    
		                
		            <!-- <hr class="whiter" />
	                    
	                    	<h2>物联网设备环境</h2>
	                        <h4 class="page-title">设备ID：{{sensor.deviceId}} || 监控地址：{{sensor.monitoringaddress}}</h4>
	                     
				               <div class="block-area">
				                   <div class="row">
				                       <div class="col-md-3 col-xs-6">
				                           <div class="tile quick-stats">
				                               <div id="stats-line-2" class="pull-left"></div>
				                               <div class="data">
				                                   <h2>{{sensor.temperature}}</h2>
				                                   <small>实时温度</small>
				                               </div>
				                           </div>
				                       </div>
				
				                       <div class="col-md-3 col-xs-6">
				                           <div class="tile quick-stats media">
				                               <div id="stats-line-3" class="pull-left"></div>
				                               <div class="media-body">
				                                   <h2 >{{sensor.humidity}}</h2>
				                                   <small>实时湿度</small>
				                               </div>
				                           </div>
				                       </div>
				
				                       <div class="col-md-3 col-xs-6">
				                           <div class="tile quick-stats media">
				
				                               <div id="stats-line-4" class="pull-left"></div>
				
				                               <div class="media-body">
				                                   <h2 >{{sensor.brightness}}</h2>
				                                   <small>实时光照值</small>
				                               </div>
				                           </div>
				                       </div>
				
				                       <div class="col-md-3 col-xs-6">
				                           <div class="tile quick-stats media">
				                               <div id="stats-line" class="pull-left"></div>
				                               <div class="media-body">
				                                   <h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{sensor.time}}</h4>
				                                   <h4>&nbsp;</h4>
				                                   <small>时间</small>
				                               </div>
				                           </div>
				                       </div>
				
				                   </div>
				
				        </div>
				       <hr class="whiter" />
				
              

		               
		                <hr class="whiter" />
               			
		               <div style="margin-left: 30px;">
			            <h3 class="block-title" style="margin-left: -10px;">Input Masking</h3>

						<p>显示屏</p>	                    	                  
			                    <div class="input-group col-md-6" style="margin-bottom: 20px;">
									<img src="http://10.21.16.112:18080/?action=stream" alt="http://10.21.16.112:18080/?action=stream" class="shrinkToFit" width="477" height="358">
			                           <div class="uneditable-input form-control"></div>
			                           <div class="input-group-btn">
			                           		<span class="btn btn-file btn-alt btn-sm">

			                               	<span class="fileupload-new">更换</span>
			                           		</span>
			                           </div>
								</div>
								
								<p>通知</p>	                    	                  
			                       <div class="input-group col-md-6" style="margin-bottom: 20px;">

									   <input class="uneditable-input form-control" contenteditable="true" type="text"    ng-model="title"/><br>
			                           <div class="input-group-btn" >
			                           <span class="btn btn-file btn-alt btn-sm">
			                               <span class="fileupload-new" ng-click="Btnled()">播报</span>
			                           </span>
			                           </div>
								</div>
								
								<p>音乐</p>	                    	                  
			                       <div class="input-group col-md-6" style="margin-bottom: 20px;">
			                           <div class="uneditable-input form-control">
			                              
			                           </div>
			                           <div class="input-group-btn">
			                           <span class="btn btn-file btn-alt btn-sm">
			                               <span class="fileupload-new">立刻播放</span>
			                           </span>
			                           </div>
			                            <div class="input-group-btn">
			                           <span class="btn btn-file btn-alt btn-sm">
			                               <span class="fileupload-new">加入播放列表</span>
			                           </span>
			                           </div>
								</div>
								
			                    <p>补光设备</p>	                    	                  
			                       <div class="input-group col-md-6" style="margin-bottom: 20px;">
			                           
			                           <div class="input-group-btn">
			                           <span class="btn btn-file btn-alt btn-sm">
			                               <span class="fileupload-new" ng-click="Btnled(0)">开灯</span>
			                           </span>
			                           <span class="btn btn-file btn-alt btn-sm">
			                               <span class="fileupload-new" ng-click="Btnled(1)">关灯</span>
			                           </span>
			                           <span class="btn btn-file btn-alt btn-sm">
			                               <span class="fileupload-new" ng-click="Btnled(2)">闪烁</span>
			                           </span>
			                           </div>
			                           
								</div>        
		                       
		                   
		               </div>
		               <hr class="whiter" /> -->
		               
		               
				        
                    	
                        
                        
			                            
	                   
	                  
        </div>
        <!-- Javascript Libraries -->
        <script type="text/javascript" src="js/jquery-3.3.1.min.js" ></script>
    	<script type="text/javascript" src="js/echarts.js" ></script>
        <script type="text/javascript">
        var app=angular.module("myApp",[]);
        app.controller("myCtrl",function($scope,$http){
			var storeid=JSON.parse(localStorage.getItem("storeid"));
			$scope.storeid=storeid;
			// $scope.store = null;
			// $http({method:'get',url:'http://localhost:8080/generator/store/info/'+storeid})
			// 	.success(function(data){
			// 		console.log(data);//打印从后台接收的数据
			// 		$scope.store = data.store;//将数据赋值给angular模型变量
			// 	});
			// $scope.accesstostafflist=null;
			// 	$http({method:'get',url:'http://localhost:8080/generator/accesstostaff/infostoreId/'+storeid})
			// 	.success(function(data){
			// 		console.log(data);//打印从后台接收的数据
			// 		$scope.accesstostafflist = data.accesstostafflist;
			// 	});

			$scope.pagelist=null;
				$http({method:'get',url:'http://localhost:8080/xsglxt/commodity/list'})
				.success(function(data){
					console.log(data);//打印从后台接收的数据
					$scope.pagelist = data.pagelist;
					console.log(data.pagelist[0]);
				});
				
        	function myInfo(){
	   	       	$scope.accesstostafflist=null;
	   	           $http({method:'get',url:'http://localhost:8080/generator/accesstostaff/infostoreId/'+storeid})
	   	           .success(function(data){
	   	               console.log(data);//打印从后台接收的数据
	   	               $scope.accesstostafflist = data.accesstostafflist;
	   	           });
   	   		}
        		
        	function myInfo2(){
    			$scope.store = null;
		         		
		   		$http({method:'get',url:'http://localhost:8080/generator/store/info/'+storeid})
		            .success(function(data){
		                console.log(data);//打印从后台接收的数据
		                $scope.store = data.store;//将数据赋值给angular模型变量
		            });
			
	   		}
			$scope.Btnled = function () {
            	 //方法1
	           	var actionObj = {
					
						date: "demoData",
						spec: "demoData",
						content: "demoData",
						serialVersionUID: 0,
						price: 0,
						name: "demoData",
						marketprice: 0


						// userid :"11",
						// title:  $scope.title,

	        		};	
           	
            	var res = $http.post('http://localhost:8080/xsglxt/commodity/realTimeRefresh',actionObj);
	       		res.success(function(data) {
	       			console.log(data);
					   $http({method:'get',url:'http://localhost:8080/xsglxt/commodity/list'})
				.success(function(data){
					console.log(data);//打印从后台接收的数据
					$scope.pagelist = data.pagelist;
					console.log(data.pagelist[0]);
				});
	       		});   
            }
			$scope.Btnled2 = function () {
            	 //方法2
	           	var actionObj = {
						// userid :"11",
						name: $scope.title,
	        		};	
					console.log(actionObj.name);
            	var res = $http.post('http://localhost:8080/xsglxt/commodity/namelist/'+$scope.title);
	       		res.success(function(data) {
	       			console.log(data);
					$scope.pagelist = data.pagelist;
	       		});   
            }
	   	$scope.Btnled3 = function (name,date) {
            	 //方法13
	           	
				console.log(name,date);
            	var res = $http.get('http://localhost:8080/xsglxt/commodity/delete?name='+name+'&date='+date);
	       		res.success(function(data) {
	       			console.log(data);
					   $http({method:'get',url:'http://localhost:8080/xsglxt/commodity/list'})
				.success(function(data){
					console.log(data);//打印从后台接收的数据
					$scope.pagelist = data.pagelist;
					console.log(data.pagelist[0]);
				});
	       		});   
            }
        	function hisdata(){
            	//请求历史数据
                $http({method:'get',url:'rest/deviceAndHisData'})
                .success(function(data){
                    console.log(data);//打印从后台接收的数据
                    //绘制图形
                    $.each(data.data, function(i, item) {
        					temperature[i]=item.temperature;
        					humidity[i]=item.humidity;
        					time[i]=item.time;
        				});
                    console.log("wdwdwdwwdwwdwd"+temperature);
                    console.log("sjsjsj"+time);
                    line(time,temperature,humidity);
                });
            }
        	var timeOut1=setInterval(myInfo,10000);
        	var timeOut3=setInterval(myInfo2,10000);
        	var timeOut2=setInterval(hisdata,10000);
	   		var hisdata=[];
	   		var temperature=[];
	   		var time=[];
	   		var humidity=[];
   		    $scope.$on("$destroy", function() {
   		   		$interval.cancel(timeOut1);
   		   		$interval.cancel(timeOut2);
   		   		$interval.cancel(timeOut3);
   		   	 });
   		 
   		//Line Chart
   		
   		  function line(time,temperature,humidity) {
	   			var chart = document.getElementById("someline");
	   	        var echart = echarts.init(chart);
	   	        var option = {
	   	          title: {
	   	            text: ''
	   	          },
	   	          tooltip : {
	   	            trigger: 'axis'
	   	          },
	   	          legend: {
	   	            data:['温度','湿度']
	   	          },
	   	          toolbox: {
	   	            feature: {
	   	              saveAsImage: {}
	   	            }
	   	          },
	   	          grid: {
	   	            left: '3%',
	   	            right: '4%',
	   	            bottom: '3%',
	   	            containLabel: true
	   	          },
	   	          xAxis : [
	   	            {
	   	              type : 'category',
	   	              boundaryGap : false,
	   	              data : time
	   	            }
	   	          ],
	   	          yAxis : [
	   	            {
	   	              type : 'value'
	   	            }
	   	          ],
	   	          series : [
	   	            {
	   	              name:'温度',
	   	              type:'line',
	   	              stack: '销量',
	   	              areaStyle: {normal: {}},
	   	              data:temperature
	   	            },
	   	            {
	   	              name:'湿度',
	   	              type:'line',
	   	              stack: '销量',
	   	              areaStyle: {normal: {}},
	   	              data:humidity
	   	            }
	   	          ]
	   	        };
	   	        echart.setOption(option);
   		  };
        });
	    
       </script>
       <!-- Javascript Libraries -->
        <!-- jQuery -->
        <script src="js/jquery.min.js"></script> <!-- jQuery Library -->
        
        <!-- Bootstrap -->
        <script src="js/bootstrap.min.js"></script>
        
        <!-- UX -->
        <script src="js/scroll.min.js"></script> <!-- Custom Scrollbar -->
        
        <!-- Other -->
        <script src="js/calendar.min.js"></script> <!-- Calendar -->
        <script src="js/feeds.min.js"></script> <!-- News Feeds -->
        
        
        <!-- All JS functions -->
        <script src="js/functions.js"></script>
</body>
   
 <script >
function doSubmitForm(){
	var form=document.getElementById('myform');
	form.submit();
	return true;
}
</script>
</html>